<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="author" content="Jonathan M. Hill" />

<meta name="date" content="2018-09-20" />

<title>Introduction</title>






<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0Aa%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%20code%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%0A" rel="stylesheet" type="text/css" />

</head>

<body>




<h1 class="title toc-ignore">Introduction</h1>
<h4 class="author"><em>Jonathan M. Hill</em></h4>
<h4 class="date"><em>2018-09-20</em></h4>



<p><a href="https://codecov.io/github/ficonsulting/RInno"><img src="" alt="codecov" /></a> <a href="http://www.repostatus.org/#active"><img src="" alt="Project Status: Active - The project has reached a stable, usable state and is being actively developed." /></a></p>
<p>RInno makes it easy to install local shiny apps by providing an interface between R, <a href="http://www.jrsoftware.org/isinfo.php">Inno Setup</a>, an installer for Windows programs (sorry Mac and Linux users), and <a href="https://electronjs.org/">Electron</a>, a modern desktop framework used by companies like Github, Slack, Microsoft, Facebook and Docker. RInno is designed to be simple to use (two lines of code at a minimum), yet comprehensive.</p>
<p>If a user does not have R installed, the RInno installer can be configured to ask them to install R along with a shiny app, <code>include_R = TRUE</code>. And similar to Dr. Lee Pang’s <a href="https://github.com/wleepang/DesktopDeployR">DesktopDeployR</a> project, RInno provides a framework for managing software dependencies and error logging features. However, RInno also supports GitHub package dependencies, continuous installation (auto-update on start up), and it is easier to manage with <code>create_app</code>, the main RInno function. DesktopDeployR requires many manual adjustments and a deep understanding of the entire framework to use, but RInno can be learned incrementally and changes automatically flow down stream. You don’t need to remember the 100+ places impacted by changing <code>app_dir</code>. RInno only requires a high-level understanding of what you’d like to accomplish.</p>
<div id="getting-started" class="section level2">
<h2>Getting Started</h2>
<pre><code># Get remotes package
install.packages(&quot;remotes&quot;); require(remotes)

# Use install_github to get RInno
install_github(&quot;ficonsulting/RInno&quot;)

# Require Package
require(RInno)

# Use RInno to get Inno Setup
install_inno()</code></pre>
</div>
<div id="minimal-example" class="section level2">
<h2>Minimal example</h2>
<p>Once you have developed a shiny app, you can build an installer with <code>create_app</code> followed by <code>compile_iss</code>.</p>
<pre><code># Example app included with RInno package
example_app(app_dir = &quot;app&quot;)

# Build an installer
create_app(app_name = &quot;Your appname&quot;, app_dir = &quot;app&quot;)
compile_iss()</code></pre>
<p><code>create_app</code> creates an installation framework in your app’s directory, <code>app_dir</code>. The main components are a file called “app_name.iss” and the “nativefier-app” directory. You can perform minor customizations before you call <code>compile_iss</code>. For example, you can replace the default/setup icon at <a href="http://www.flaticon.com/">Flaticon.com</a>, or you can customize the pre-/post- install messages, <em>infobefore.txt</em> and <em>infoafter.txt</em>. Just remember, the default values (i.e. <code>create_app(info_after = &quot;infobefore.txt&quot;)</code>) for those files have not changed. The Inno Setup Script (ISS), <em>app_name.iss</em>, will look for <em>default.ico</em> and try to use it until you update the script or call <code>create_app</code> with the new icon’s file name (i.e. <code>create_app(app_icon = &quot;new.ico&quot;)</code>). Likewise, the Electron app will need to be recompiled to capture any manual changes to files in <code>app_dir</code>.</p>
<p>Electron is now used to render the shiny app’s UI. All other <code>user_browser</code> options will be deprecated in future releases.</p>
</div>
<div id="ui.r-requirements" class="section level2">
<h2>ui.R Requirements</h2>
<p>In order to replace Electron’s logo with your app’s icon, add something like this to your ui.R file:</p>
<pre><code>fluidPage(
  tags$head(
    tags$link(
      rel = &quot;icon&quot;, 
      type = &quot;image/x-icon&quot;, 
      href = &quot;http://localhost:1984/default.ico&quot;)
  )
)</code></pre>
</div>
<div id="server.r-requirements" class="section level2">
<h2>server.R Requirements</h2>
<p>In order to close the app when your user’s session completes:</p>
<ol style="list-style-type: decimal">
<li>Add <code>session</code> to your <code>server</code> function</li>
<li>Call <code>stopApp()</code> when the session ends</li>
</ol>
<pre><code>function(input, output, session) {

  if (!interactive()) {
    session$onSessionEnded(function() {
      stopApp()
      q(&quot;no&quot;)
    })
  }
}</code></pre>
<p>If you forget to do this, users will complain that their icons are broken and rightly blame you for it (an R session will be running in the background hosting the app, but they will need to press ctrl + alt + delete and use their task manager to close it). <strong>Not cool</strong>.</p>
</div>
<div id="package-dependency-management" class="section level2">
<h2>Package Dependency Management</h2>
<p>Provide a named character vector of packages to <code>create_app</code>, and RInno will download them and install them with your shiny app. RInno downloads windows binaries from CRAN for the listed packages and their dependencies with <code>tools::package_dependencies(packages = pkgs, recursive = TRUE)</code>.</p>
<pre><code>create_app(
  app_name = &quot;myapp&quot;, 
  app_dir = &quot;app&quot;,
  pkgs = c(&quot;shiny&quot;, &quot;jsonlite&quot;, &quot;httr&quot;)
)</code></pre>
<p>For <code>remotes</code>, Github source files are compiled into windows binaries. Bitbucket will be supported in a future release.</p>
</div>
<div id="custom-installations" class="section level2">
<h2>Custom Installations</h2>
<p>If you would like to create a custom installer from within R, you can slowly build up to it with <code>create_app</code>, like this:</p>
<pre><code>create_app(
  app_name    = &quot;My AppName&quot;, 
  app_dir     = &quot;My/app/path&quot;,
  dir_out     = &quot;wizard&quot;,
  pkgs        = c(&quot;jsonlite&quot;, &quot;shiny&quot;, &quot;magrittr&quot;, &quot;xkcd&quot;),  # CRAN-like repo packages
  remotes     = c(&quot;talgalili/installr&quot;, &quot;daattali/shinyjs&quot;), # GitHub packages
  include_R   = TRUE,     # Download R and install it with your app, if necessary
  R_version   = &quot;2.2.1&quot;,  # Old versions of R
  privilege   = &quot;high&quot;,   # Admin only installation
  default_dir = &quot;pf&quot;)     # Install app in to Program Files</code></pre>
<p><code>create_app</code> passes its arguments to most of the other support functions in RInno. You can (and probably should) specify most things there and they will get passed on. Alternatively, you can provide instructions directly to those support functions like this:</p>
<pre><code># Copy installation scripts (JavaScript, icons, infobefore.txt, package_manager.R, launch_app.R)
copy_installation(app_dir = &quot;my/app/path&quot;)

# If your users need R installed:
get_R(app_dir = &quot;my/app/path&quot;, R_version = &quot;2.2.1&quot;)

# Create batch file
create_bat(app_name = &quot;My AppName&quot;, app_dir = &quot;my/app/path&quot;)

# Create app config file
create_config(app_name = &quot;My AppName&quot;, R_version = &quot;2.2.1&quot;, app_dir = &quot;my/app/path&quot;,
  pkgs = c(&quot;jsonlite&quot;, &quot;shiny&quot;, &quot;magrittr&quot;, &quot;dplyr&quot;, &quot;caret&quot;, &quot;xkcd&quot;))

# Build the iss script
start_iss(app_name = &quot;My AppName&quot;) %&gt;%

  # C-like directives
  directives_section(R_version   = &quot;2.2.1&quot;, 
             include_R   = TRUE,
             app_version = &quot;0.1.2&quot;,
             publisher   = &quot;Your Company&quot;, 
             main_url    = &quot;yourcompany.com&quot;) %&gt;%

  # Setup Section
  setup_section(output_dir  = &quot;wizard&quot;, 
        app_version = &quot;0.1.2&quot;,
        default_dir = &quot;pf&quot;, 
        privilege   = &quot;high&quot;,
        inst_readme = &quot;pre-install instructions.txt&quot;, 
        setup_icon  = &quot;myicon.ico&quot;,
        pub_url     = &quot;mycompany.com&quot;, 
        sup_url     = &quot;mycompany.github.com/issues&quot;,
        upd_url     = &quot;mycompany.github.com&quot;) %&gt;%

  # Languages Section
  languages_section() %&gt;%

  # Tasks Section
  tasks_section(desktop_icon = FALSE) %&gt;%

  # Files Section
  files_section(app_dir = &quot;my/app/path&quot;, file_list = &quot;path/to/extra/files&quot;) %&gt;%

  # Icons Section
  icons_section(app_desc       = &quot;This is my local shiny app&quot;,
        app_icon       = &quot;notdefault.ico&quot;,
        prog_menu_icon = FALSE,
        desktop_icon   = FALSE) %&gt;%

  # Execution &amp; Pascal code to check registry during installation
  # If the user has R, don't give them an extra copy
  # If the user needs R, give it to them
  run_section() %&gt;%
  code_section() %&gt;%

  # Write the Inno Setup script
  writeLines(file.path(&quot;my/app/path&quot;, &quot;My AppName.iss&quot;))

  # Check your files, then
  compile_iss()
</code></pre>
<p>Feel free to read the Inno Setup <a href="http://www.jrsoftware.org/ishelp/">documentation</a> and RInno’s documentation to get a sense for what is possible. Also, please suggest useful features or build them yourself! We have a very positive culture at FI Consulting, and we would love to get your feedback.</p>
<p>Please note that this project has a <a href="https://github.com/ficonsulting/RInno/blob/master/CONDUCT.md">Contributor Code of Conduct</a>. By participating in this project you agree to abide by its terms.</p>
</div>
<div id="license" class="section level2">
<h2>License</h2>
<p>The RInno package is licensed under the GPLv3. See LICENSE for details.</p>
</div>



<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>
